package com.ssm.juc.theadpool.task;

import com.ssm.juc.theadpool.domain.Order;
import lombok.extern.slf4j.Slf4j;

import java.util.Random;

/**
 * 订单提交任务
 */
@Slf4j
public class OrderTask implements Runnable {

    private final Order order;

    public OrderTask(Order order) {
        this.order = order;
    }

    @Override
    public void run() {
        int time = 20 + new Random().nextInt(10);
        try {
            Thread.sleep(time);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        log.info("订单处理完成, orderId:{}.", order.getOrderId());
    }
}
